/*
 * @Author: your name
 * @Date: 2020-07-22 22:13:50
 * @LastEditTime2020-11-22 14:23:36
 * @LastEditorsPlease set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \STM32F103_FreeRTOS\User\app\shell\shell.h
 */ 
#ifndef _SHELL_H_
#define _SHELL_H_

#include "shell_queue.h"
#include "shell_cmd.h"
#include "common_types.h"
#include "FreeRTOS.h"
#include "semphr.h"

#define SHELL_TASK_STACK_SIZE      configMINIMAL_STACK_SIZE

#define SHELL_HISTORY_SIZE         5
#define SHELL_LINE_LENGTH          100

#define OS_SHELL_QUEUE_SIZE        (1u)   /* 1 Byte */
#define OS_SHELL_QUEUE_LENGTH      (128u) /* 128 Length */

#define SHELL_PROMPT               "shell> "

typedef enum shell_state
{
    SHELL_IDEL = 0,
}shell_state_t;

typedef struct Shell
{
    uint8_t state;
    uint16_t history_curr;
    uint16_t history_tail;
    uint16_t history_num;
    uint16_t line_curpos;
    uint16_t line_endpos;
    char line[SHELL_LINE_LENGTH];
    char history[SHELL_HISTORY_SIZE][SHELL_LINE_LENGTH];
    uint8_t (*read)(uint8_t *data);
    uint8_t (*write)(uint8_t data);
}Shell_t;

/* Shell Queue */
extern QueueHandle_t g_shell_queue;

/* Shell Semapare */
extern SemaphoreHandle_t ShellPrintCmdSemapBinary;

/* shell task */
extern void shell_task(void *para);
extern StaticTask_t shell_task_tcb;
extern StackType_t shell_task_stack[SHELL_TASK_STACK_SIZE];

#endif


